﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Data;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace TFSCodeReviewHelper
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window, INotifyPropertyChanged
    {
        #region INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string strPropertyName)
        {
            if (null != PropertyChanged)
                PropertyChanged(this, new PropertyChangedEventArgs(strPropertyName));
        }
        #endregion

        private WorkItem _SelectedWorkItem;

        public WorkItem SelectedWorkItem
        {
            get { return _SelectedWorkItem; }
            set
            {
                _SelectedWorkItem = value;
                OnPropertyChanged("SelectedWorkItem");
            }
        }

        public MainWindow()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Called before InitializeComponent() is finished from the constructor.  Performs final
        /// construction work.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            _AssetGrid.WorkItemChanges = new WorkItemChanges();
            TFSInterface.ConnectToServer();

        }

        private void GetWorkItem_Click(object sender, RoutedEventArgs e)
        {
            //SelectedWorkItem = TFSInterface.GetWorkItemFromId(1000);
            _WorkItemVisualizer.DataContext = new WorkItemVisualizerPresentation(SelectedWorkItem);
        }
    }
}
